package com.cy.law.vo;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 树形结构类
 */
public class Tree {
    // 树的图标
    public static final String TREE_FOLDER = "tree-folder";
    public static final String TREE_FOLDER_OPEN = "tree-folder-open";
    public static final String TREE_VIDEO = "tree-video";
    public static final String TREE_UNIT = "icon-unit";
    public static final String TREE_PROCESS = "icon-process";
    public static final String TREE_HUMAN = "icon-human";
    public static final String TREE_MULTI_HUMAN = "icon-multi-human";
    public static final String TREE_MONITOR = "icon-monitor";
    //在tree-1.4.1.css 中修改想应的css属性即可,同时需要在images下添加相应的图片

    //树状态展开
    public static final String TREE_STATE_OPEN = "open";
    //树状态闭合
    public static final String TREE_STATE_CLOSED = "closed";
    public static final int TREE_ROOT_ID = 0;
    public static final String TREE_ROOT_ID_STR = "0";

    protected String id;
    protected String text;
    protected String iconCls;
    protected String state;
    protected boolean checked = false;
    protected List<Tree> children = new ArrayList<Tree>();
    protected Map<String, Object> attributes = new HashMap<String, Object>();

    public Tree() {

    }

    public Tree(String id, String text) {
        this.id = id;
        this.text = text;
    }

    public Tree(int id, String text) {
        this.id = Integer.toString(id);
        this.text = text;
    }

    public List<Tree> getChildren() {
        return children;
    }

    public void setChildren(List<Tree> children) {
        this.children = children;
    }

    public String getIconCls() {
        return iconCls;
    }

    public void setIconCls(String iconCls) {
        this.iconCls = iconCls;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setId(int id) {
        this.id = Integer.toString(id);
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public Map<String, Object> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, Object> attributes) {
        this.attributes = attributes;
    }

    public void addAttribute(String key, Object value) {
        if (this.attributes == null) {
            this.attributes = new HashMap<String, Object>();
        }
        this.attributes.put(key, value);
    }
}
